package com.fzl.springblogdemo.util;

import com.fzl.springblogdemo.pojo.dataobject.BlogInfo;
import com.fzl.springblogdemo.pojo.dataobject.UserInfo;
import com.fzl.springblogdemo.pojo.request.UpdateBlogRequest;
import com.fzl.springblogdemo.pojo.request.UserRegisterRequest;
import com.fzl.springblogdemo.pojo.response.BlogInfoResponse;
import com.fzl.springblogdemo.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

public class BeanTransUtils {
    public static BlogInfoResponse trans(BlogInfo blogInfo){
        if(blogInfo == null){
            //ToDo 待做事情
            return null;
        }
        BlogInfoResponse blogInfoResponse=new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo,blogInfoResponse);
        return blogInfoResponse;
    }

        public static UserInfoResponse trans(UserInfo userInfo){
            if(userInfo == null){
                //ToDo 待做事情
                return null;
            }
            UserInfoResponse userInfoResponse=new UserInfoResponse();
            BeanUtils.copyProperties(userInfo,userInfoResponse);
            return userInfoResponse;
        }

    public static BlogInfo trans(UpdateBlogRequest request){
        if(request == null){
            //ToDo 待做事情
            return null;
        }
        BlogInfo blogInfo=new BlogInfo();
        BeanUtils.copyProperties(request,blogInfo);
        return blogInfo;
    }

    public static UserInfo trans(UserRegisterRequest request){
        if(request == null){
            //ToDo 待做事情
            return null;
        }
       UserInfo userInfo=new UserInfo();
        BeanUtils.copyProperties(request,userInfo);
        return userInfo;
    }


}
